package com.syq.utils;

import com.syq.pojo.SysUserInfo;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @author Sun Yueqi
 * @version 1.00
 * @time 2022/5/29 22:21
 */
public class SecurityUtils {

    public static SysUserInfo getUserinfo(boolean test){
        if (test){
            SysUserInfo sysUserInfo=new SysUserInfo();
            sysUserInfo.setUsername("ceshiyonghu");
            sysUserInfo.setUId(-1L);
            return sysUserInfo;
        }
        return (SysUserInfo) ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getSession().getAttribute("user");
    }
}
